#include<iostream>
using namespace std;

class A
{
	friend A operator+(const A&, const A&);

	public:
		A()
		{
			this->i = 1124;
			cout << "constructed" << endl;
		}
		~A()
		{
			//cout << "destructed" << endl;
		}
		A(const A& a)
		{
			this->i = a.i;
			cout << "copy constructed" << endl;
		}
		A& operator=(const A &a)
		{
			this->i = a.i;
			cout << "operator=" << endl;
			return *this;
		}

	private:
		int i;
};

A operator+(const A &a, const A &b)
{
	A re;
	re.i = a.i + b.i;
	cout << "operator+" <<endl;
}


int main(int argc, char *argv[])
{
	A a,b;
	cout << "===================================" << endl;
	// c constructed, no temp object, no operator=
	A c = a + b;
	cout << "===================================" << endl;
	// d constructed, temp object constructed, operator= invoked
	A d;
	d = a + b;
	cout << "===================================" << endl;
	// temp object constructed
	a + b;
	return 0;
}
